package com.color.admin.common.swagger.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;

/**
 * @author HaiQiu
 * @date 2021/11/19
 * SpringDoc配置
 */
@OpenAPIDefinition(security = @io.swagger.v3.oas.annotations.security.SecurityRequirement(name = "JWT"))
//@SecurityScheme(type = SecuritySchemeType.APIKEY, name = "JWT",paramName = "Authorization",
//        in = SecuritySchemeIn.HEADER,description = "token请求头，header里携带name：Authorization,value：Bearer+token 进行授权（自定义头部形式）")
@io.swagger.v3.oas.annotations.security.SecurityScheme(type = SecuritySchemeType.HTTP, scheme = "bearer",name = "JWT",
        in = SecuritySchemeIn.HEADER,description = "标准http+Authorization+bearer形式")
public abstract class SpringDocConfig {

    @Bean
    public OpenAPI openAPI(){
        return new OpenAPI()
                .info(this.info());
    }


    private Info info(){
        return new Info().title("Color-Admin(开发接口文档)")
                .description("Color项目快速开发脚手架")
                .version("2.0")
                .contact(this.contact())
                .license(this.license());
    }

    private Contact contact(){
        return new Contact()
                .email("1576696125@qq.com")
                .name("API Support")
                .url("https://www.baidu.com");
    }

    private License license(){
        return new License()
                .name("Apache 2.0")
                .url("https://www.apache.org/licenses/LICENSE-2.0.html");
    }
}
